package com.haixiaoke.saas.lock.service.impl;

import java.util.List;

import com.haixiaoke.saas.common.constant.DeviceLockConstants;
import com.haixiaoke.saas.common.utils.DateUtils;
import com.haixiaoke.saas.lock.domain.LockOperatingRecord;
import com.haixiaoke.saas.lock.mapper.LockOperatingRecordMapper;
import com.haixiaoke.saas.lock.service.ILockOperatingRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 锁操作记录Service业务层处理
 *
 * @author xiaolong
 * @date 2025-04-11
 */
@Service
public class LockOperatingRecordServiceImpl implements ILockOperatingRecordService {
    @Autowired
    private LockOperatingRecordMapper lockOperatingRecordMapper;

    /**
     * 查询锁操作记录
     *
     * @param lockOperatingRecordId 锁操作记录主键
     * @return 锁操作记录
     */
    @Override
    public LockOperatingRecord selectLockOperatingRecordByLockOperatingRecordId(Long lockOperatingRecordId) {
        return lockOperatingRecordMapper.selectLockOperatingRecordByLockOperatingRecordId(lockOperatingRecordId);
    }

    /**
     * 查询锁操作记录列表
     *
     * @param lockOperatingRecord 锁操作记录
     * @return 锁操作记录
     */
    @Override
    public List<LockOperatingRecord> selectLockOperatingRecordList(LockOperatingRecord lockOperatingRecord) {
        return lockOperatingRecordMapper.selectLockOperatingRecordList(lockOperatingRecord);
    }

    /**
     * 新增锁操作记录
     *
     * @param lockOperatingRecord 锁操作记录
     * @return 结果
     */
    @Override
    public int insertLockOperatingRecord(LockOperatingRecord lockOperatingRecord) {
        lockOperatingRecord.setCreateTime(DateUtils.getNowDate());
        return lockOperatingRecordMapper.insertLockOperatingRecord(lockOperatingRecord);
    }

    /**
     * 修改锁操作记录
     *
     * @param lockOperatingRecord 锁操作记录
     * @return 结果
     */
    @Override
    public int updateLockOperatingRecord(LockOperatingRecord lockOperatingRecord) {
        return lockOperatingRecordMapper.updateLockOperatingRecord(lockOperatingRecord);
    }

    /**
     * 批量删除锁操作记录
     *
     * @param lockOperatingRecordIds 需要删除的锁操作记录主键
     * @return 结果
     */
    @Override
    public int deleteLockOperatingRecordByLockOperatingRecordIds(Long[] lockOperatingRecordIds) {
        return lockOperatingRecordMapper.deleteLockOperatingRecordByLockOperatingRecordIds(lockOperatingRecordIds);
    }

    /**
     * 删除锁操作记录信息
     *
     * @param lockOperatingRecordId 锁操作记录主键
     * @return 结果
     */
    @Override
    public int deleteLockOperatingRecordByLockOperatingRecordId(Long lockOperatingRecordId) {
        return lockOperatingRecordMapper.deleteLockOperatingRecordByLockOperatingRecordId(lockOperatingRecordId);
    }

    /**
     * 添加锁操作记录
     */
    @Override
    public int addLockOperatingRecord(Long lockId, String userName, String operatingType, String operatingContent) {
        LockOperatingRecord lockOperatingRecord = new LockOperatingRecord(lockId, operatingType, operatingContent);
        lockOperatingRecord.setCreateBy(userName);
        lockOperatingRecord.setCreateTime(DateUtils.getNowDate());
        return lockOperatingRecordMapper.insertLockOperatingRecord(lockOperatingRecord);
    }

    @Override
    public int batchInsertLockOperatingRecord(List<LockOperatingRecord> lockOperatingRecordList) {
        return lockOperatingRecordMapper.batchInsertLockOperatingRecord(lockOperatingRecordList);
    }
}
